import React from 'react';

export class CtrlForm extends React.Component {
  state = {
    txt: 'hello',
    xx: 'xxx',
  };

  handleTxt = (e) => {
    // 将输入框的值设置到组件状态中
    this.setState({
      txt: e.target.value,
    });
  };

  render() {
    // value的显示状态此时就由React的状态控制
    return (
      <input type="text" value={this.state.txt} onChange={this.handleTxt} />
    );
  }
}
